package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.JsonResult.JsonResult;
import cn.wolfcode.wolf2w.cache.service.IUserInfoRedisService;
import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.domain.StrategyCatalog;
import cn.wolfcode.wolf2w.domain.Travel;
import cn.wolfcode.wolf2w.domain.UserInfo;
import cn.wolfcode.wolf2w.query.StrategyQuery;
import cn.wolfcode.wolf2w.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/destinations")
public class DestinationController {
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;
    @GetMapping("/hotRegion")
    public Object hotRegion(){
        return JsonResult.success(regionService.queryHotRegion());
    }

    @GetMapping("/search")
    public Object search(String regionId){
        return JsonResult.success(destinationService.queryDestByRegionIdForApi(regionId));
    }
    @GetMapping("/toasts")
    public Object toasts(String destId){
        return JsonResult.success(destinationService.queryToasts(destId));
    }
    @GetMapping("/catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> list= strategyCatalogService.queryCatalogByDestId(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/strategies/viewnumTop3")
    public Object strategiesViewnumTop3(String destId){
        List<Strategy> list= strategyService.queryViewnumTop3(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/travels/viewnumTop3")
    public Object travelViewnumTop3(String destId){
        List<Travel> list= travelService.getViewnumTop3(destId);
        return JsonResult.success(list);
    }
    @GetMapping("/detail")
    public Object detail(String id){
        return JsonResult.success(destinationService.get(id));
    }


}
